www.gusucode.com > VC++ 酒店管理系统-源码程序 > VC++ 酒店管理系统-源码程序/code/hotel2003/RoomRegister.cpp
//Download by http://www.NewXing.com // RoomRegister.cpp : implementation file // #include "stdafx.h" #include "qq.h" #include "RoomRegister.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif #include "InfoSet.h" ///////////////////////////////////////////////////////////////////////////// // CRoomRegister dialog CGuestRegister::CGuestRegister(CWnd* pParent /*=NULL*/) : CDialog(CGuestRegister::IDD, pParent) { //{{AFX_DATA_INIT(CRoomRegister) m_nCertificatType = 0; m_nSex = -1; m_nGuestType = -1; Certificate="身份证"; GuestNum=0; GuestType="个人"; IsMaster=false; IsMember=false; RoomCode="0"; Sex="男"; //}}AFX_DATA_INIT year=0; month=0; day=0; hour=0; minute=0; second=0; } void CGuestRegister::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CRoomRegister) DDX_Control(pDX, IDC_GROUPID, GroupID); DDX_Control(pDX, IDC_STARTTIME, StartTime); DDX_Control(pDX, IDC_CERTIFYCODE, CertifyCode); DDX_Control(pDX, IDC_GUESTNAME, Name); DDX_Control(pDX, IDC_HANDCODE, HandCode); DDX_Radio(pDX, IDC_RADIO1, m_nCertificatType); DDX_Radio(pDX, IDC_RADIO3, m_nSex); DDX_Radio(pDX, IDC_RADIO5, m_nGuestType); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CGuestRegister, CDialog) //{{AFX_MSG_MAP(CRoomRegister) ON_BN_CLICKED(IDC_RADIO1, OnCertificatType) ON_BN_CLICKED(IDC_RADIO3, OnSex) ON_BN_CLICKED(IDC_RADIO5, OnGuestType) ON_BN_CLICKED(IDC_RADIO2, OnCertificatType) ON_BN_CLICKED(IDC_RADIO4, OnSex) ON_BN_CLICKED(IDC_RADIO6, OnGuestType) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CRoomRegister message handlers void CGuestRegister::OnOK() { // TODO: Add extra validation here UpdateData(TRUE); CString str; HandCode.GetWindowText(str); /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 检查数据库中是否已经存在这个手牌号码 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ bool bhas=false; if(!m_GuestInfoSet.Open()) { MessageBox("打开数据库失败!","数据库错误",MB_OK); return; } while (!m_GuestInfoSet.IsEOF()) { if(str==m_GuestInfoSet.m_HandCode) { bhas=true; } m_GuestInfoSet.MoveNext(); } m_GuestInfoSet.Close(); if(bhas) { MessageBox("已经注册了这个客人!","注册错误",MB_OK); return; } ////////////////////////////////////////////////////////////////////////// /* * 检查身份证的号码是否为15位或者为18位 */ CString strCertifyCode;//证件号码 CertifyCode.GetWindowText(strCertifyCode);//获得证件号码 int nCertifyCodeLength=strCertifyCode.GetLength();//获得证件的长度 if(nCertifyCodeLength!=15&&nCertifyCodeLength!=18) { if(m_nCertificatType==0) {//若选择的是身份证 MessageBox("你的身份证的号码的位数不正确!\n应该为15位或者18位!", "身份证错误",MB_OK); return ; } } if(str!="") { /* * 判断该客人是否预定了房间 */ // [7/1/2003-11:28] if(!m_RoomDestine.Open()) { MessageBox("打开数据库失败!","数据库错误",MB_OK); return; } m_RoomDestine.MoveFirst(); while (!m_RoomDestine.IsEOF()) { if(strCertifyCode==m_RoomDestine.m_CeritifyCode) { //查找到该客人已经预定了房间 MessageBox("该客人已经预定了房间",NULL,MB_OK); } m_RoomDestine.MoveNext(); } m_RoomDestine.Close(); ////////////////////////////////////////////////////////////////////////// if(!m_GuestInfoSet.Open(AFX_DB_USE_DEFAULT_TYPE)) {//连接数据库 MessageBox("打开数据库失败!","数据库错误",MB_OK); return; } m_GuestInfoSet.AddNew();//添加一个新的空的记录集 m_GuestInfoSet.m_Certificate=Certificate; CertifyCode.GetWindowText(m_GuestInfoSet.m_CertifyCode); GroupID.GetWindowText(m_GuestInfoSet.m_GroupID); m_GuestInfoSet.m_GuestNum=GuestNum; m_GuestInfoSet.m_GuestType=GuestType; HandCode.GetWindowText(m_GuestInfoSet.m_HandCode); m_GuestInfoSet.m_IsMaster=IsMaster; m_GuestInfoSet.m_IsMember=IsMember; Name.GetWindowText(m_GuestInfoSet.m_Name); m_GuestInfoSet.m_RoomCode=RoomCode; m_GuestInfoSet.m_RoomNum=RoomNum; m_GuestInfoSet.m_Sex=Sex; m_GuestInfoSet.Update();//数据更新 m_GuestInfoSet.Close(); //关闭数据库 } ////将开始入住时间写入数据库中 if(!m_BillCheckoutInfoSet.Open()) { MessageBox("打开数据库失败!","数据库错误",MB_OK); return; } m_BillCheckoutInfoSet.AddNew(); CTime time(year,month,day,hour,minute,second,0); m_BillCheckoutInfoSet.m_StartTime=time;//写入开始时间 m_BillCheckoutInfoSet.m_HandCode=str;//写入手牌号码 m_BillCheckoutInfoSet.Update(); m_BillCheckoutInfoSet.Close();//close the DB CDialog::OnOK(); } void CGuestRegister::OnCertificatType() { // TODO: Add your control notification handler code here UpdateData(true); if(m_nCertificatType==0) { Certificate="身份证";//设置证件类型为"身份证" } if(m_nCertificatType==1) { Certificate="军人证";//设置证件类型为"军人证" } } void CGuestRegister::OnSex() { // TODO: Add your control notification handler code here this->UpdateData(true); if(m_nSex==0) { Sex="男"; } if(m_nSex==1) { Sex="女"; } } void CGuestRegister::OnGuestType() { // TODO: Add your control notification handler code here this->UpdateData(true); if(m_nGuestType==0) { GuestType="团体成员"; IsMaster=false; IsMember=true; } if(m_nGuestType==1) { GuestType="主客"; IsMember=false; IsMaster=true; } } BOOL CGuestRegister::OnInitDialog() { CDialog::OnInitDialog(); HICON m_hIcon=AfxGetApp()->LoadIcon(IDR_MAINFRAME2); this->SetIcon(m_hIcon,true);//设置对话框图标 // TODO: Add extra initialization here /*@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ 将当前的时间显示在开始入住时间栏中 @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@*/ CTime time=CTime::GetCurrentTime();//构造时间对象 CTime tm(time);//构造时间对象 year=tm.GetYear(); month=tm.GetMonth(); day=tm.GetDay(); hour=tm.GetHour(); minute=tm.GetMinute(); second=tm.GetSecond(); CString strYear,strMonth,strDay; strYear.Format("%d",year); strMonth.Format("%d",month); strDay.Format("%d",day); CString strShowText; strShowText=strYear+"-"+strMonth+"-"+strDay; CString strCurrentTime=time.Format("%H:%M:%S"); strShowText=strShowText+" "+strCurrentTime; StartTime.SetWindowText(strShowText);//显示当前时间 ////////////////////////////////////////////////////////////////////////// return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CGuestRegister::OnCancel() { // TODO: Add extra cleanup here CDialog::OnCancel(); }